<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<script language=javascript>
javascript:window.history.forward(1);
javascript:window.history.forward(-1);
</script>
<script TYPE="text/javascript">
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<s:set name="webFramework" value="#session['USERROLE']"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LM Design</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="form.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="stmenu.js"></script>
<script type="text/javascript" src="date-picker.js"></script>
</head>
<body>
<div class="bodybox">
<div class="headerbar_top"> Welcome ${currentUserDetails.name}</div>
<div class="header">

</div>
<div class="wrapper">
<div class="navigation">
<a href="http://www.dhtml-menu-builder.com"  style="display:none;visibility:hidden;">Navigation Menu</a>
		<s:if test="%{#webFramework=='Manager'}">	
		aa	
			<script type="text/javascript" src="locatationMngr.js"></script>
		</s:if>
		<s:if test="%{#webFramework=='Admin'}">		
		bb
			<script type="text/javascript" src="admin.js"></script>
		</s:if>
		<s:if test="%{#webFramework=='Operator'}">	
			<script type="text/javascript" src="operator.js"></script>
		</s:if>
		<s:if test="%{#webFramework=='Authorizer'}">		
			<script type="text/javascript" src="authorizer.js"></script>
		</s:if>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>
<!-- navigation end-->
<div class="content">
<h4>Add Transaction</h4>
			
			<tr><td></td><td><font color="#dc143c" face="verdana, arial, helvetica, sans-serif">
    <s:fielderror> </s:fielderror></font></td></tr>
			<s:form action="saveTrx" method="POST" onsubmit="return validateForm();" theme="simple" >
	<%-- 		<s:head theme="ajax" /> --%>
				<table>
				<%-- <tr>				    
				    <td align="left"><s:textfield label="Form ID" name="formId" tabindex="1"/></td>
				</tr> --%>
				<tr>		
					<td class="right"><label for="locId">Location Code</label></td>
					<td class="left">&nbsp;</td>
					<td class="left">
					<%-- 	<s:select name="locId" id="locationId" list="locations" listKey="locId" listValue="locName" headerKey="" headerValue="-- select location --" />
					 --%>	<s:select name="locId" id="locationId" list="#session['LOCLIST']" listKey="locId" listValue="locName" headerKey="" headerValue="-- select location --" />
					</td>
				</tr>
			 	<tr>
					<td class="right"><label for="amount">Amount</label></td>
					<td class="left">&nbsp;</td>
					<td class="left"><s:textfield id="amountId"  name="amount" tabindex="3"/> 
					</td>
				</tr>
				
				<tr>
					<td class="right"><label for="reason">Reason</label></td>
					<td class="left">&nbsp;</td>
					<td class="left">
					<s:select id="reasonId" headerKey="" headerValue="-- select --"
					 name="reason" list="#{'Purchased Goods':'Purchased Goods','Purchased Services':'Purchased Services','Given On Rent':'Given On Rent'}"  tabindex="4" />
					</td>
				   </tr>  
				 <tr>
				 <td class="right"><label for="itemPurchased">Item Purchased</label></td>
			    <td class="left">&nbsp;</td>
			    <td class="left"><s:textfield id="itemId" name="itemName" tabindex="5"/></td>
				</tr>
				
				<tr>
					<td class="right"><label for="trnsDate">Transaction Date</label></td>
					<td class="left">&nbsp;</td>
					<td class="left">
						<sd:datetimepicker disabled="true" displayFormat="yyyy-MM-dd" formatLength="10" name="txDate" id="dateId"></sd:datetimepicker>
					</td>				 
				</tr>
				</tr>
				<tr>
					 <td class="right"><label for="rtrnDate">Return Date</label></td>
					<td class="left">&nbsp;</td>
					<td class="left">
						<sd:datetimepicker disabled="true" id="retDateId" formatLength="10" name="retDate" displayFormat="yyyy-MM-dd" /> 
					</td>					   
				</tr>
		<%-- 		<tr>
				<td class="right"><label for="trnsDate">Transaction Date</label></td>
				<td class="left">&nbsp;</td>
				<td class="left"><s:datetimepicker id="dateId" name="txDate" displayFormat="yyyy-MM-dd"></s:datetimepicker> 
				</td>
				 
				</tr>
				<tr>
				 <td class="right"><label for="rtrnDate">Return Date</label></td>
				<td class="left">&nbsp;</td>
				<td class="left"><s:datetimepicker id="retDateId" name="retDate" displayFormat="yyyy-MM-dd"></s:datetimepicker> 
				</td> 
				   
				</tr>--%>
				<tr>
				<td class="right"><label for="intrstAmount">Interest Amount</label></td>
				<td class="left">&nbsp;</td>
				<td class="left"><s:textfield id="interestId" name="interestAmount" tabindex="8"/> 
				</td>

				</tr>
				<%-- <tr>
				    <td align="left"><s:textfield label="Person Id" name="personId" tabindex="9"/> 
				    </td>
				</tr> --%>
				<tr>
				 <td class="right"><label for="narration">Narration</label></td>
				<td class="left">&nbsp;</td>
				<td class="left"><s:textarea  id="narationId" label="Narration" name="narration" tabindex="10"></s:textarea> 
				</td>

				</tr>
				<tr>
				<td class="right"><label for="trnsType">Transaction Type</label></td>
				<td class="left">&nbsp;</td>
				<td class="left">
			   <s:radio id="trxTypeId"  label="Transaction Type" name="txTye" list="#{'Debit':'Debit','Credit':'Credit'}"  tabindex="11"/>
				</td>
				 
				</tr>
				<tr>
				 <td class="right"><label for="modeOfPayment">Mode Of Payment</label></td>
				<td class="left">&nbsp;</td>
				<td class="left">
			<s:select id="modeId"  label="Mode Of Payment" headerKey="" headerValue="-- select --"
			 name="mode" list="#{'Cash':'Cash','Cheque':'Cheque','Demand Draft':'Demand Draft','Wire Transfer':'Wire Transfer'}"  tabindex="12" />
				</td>

				</tr>  
				<%-- <tr>
				    <td align="left"><s:textfield label="Authorizer ID" name="authId" tabindex="13"></s:textfield>
				    </td>
				</tr> --%>
				
			<s:if test="%{#webFramework=='Authorizer'}">			
				<tr>
				 <td class="right"><label for="trnsStatus">Approve</label></td>
					<td class="left">&nbsp;</td>
					<td class="left"><s:checkbox  name="status" ></s:checkbox>
					</td>
				</tr>
			</s:if>
				<tr> 
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				  </tr>
				<tr>
					 <td>&nbsp;</td>
					  <td>&nbsp;</td>
				    <td>
					<s:submit value="Save Transaction" type="button"/>					
					<s:reset value="Reset" onclick="return resetForm();"></s:reset>
					
				  </tr>
				</table>
		</s:form>
</div>
<!-- content end-->
</div> 
<!-- wrapper end-->
<div class="bottom_strip"></div>
<div class="headerbar_bottom">
&copy; Copyright 2011. Dera Sacha Sauda, Sirsa-125055 (Haryana)
<br />
Designed By: DSS IT WING</div>
</div>
<script type="text/javascript">
 function resetForm(){
		 document.getElementById('amountId').value="";		
		 document.getElementById('locationId').value = "";
		 document.getElementById('reasonId').value = "";
		 document.getElementById('itemId').value = "";
		 document.getElementById('interestId').value = "";
		 document.getElementById('narationId').value = "";
		 return false;
	 }

	function validateForm(){		
		var amount = document.getElementById('amountId').value;
	
		var location1 = document.getElementById('locationId').value;
		var reason = document.getElementById('reasonId').value;
		var item = document.getElementById('itemId').value;
		var trxDate = document.getElementsByName('dojo.txDate')[0].value;
		var retDate = document.getElementsByName('dojo.retDate')[0].value;
		var interest = document.getElementById('interestId').value;
		var naration = document.getElementById('narationId').value;
		var checked = false;
		var buttons = document.getElementsByName('txTye');
		 for (var i=0; i<buttons.length; i++) 
		{ 
			 if (buttons[i].checked) {				
			  checked = true;
			  break; 
			 } 
		 }
		var mode = document.getElementById('modeId').value;

	 	var errMsg="";
		if(location1==null || location1==""){
			errMsg = errMsg + "Please Select Location \n";
		}
		if(amount==null || amount==""){
			errMsg = errMsg + "Please enter amount \n";
		}
		if(isNaN(amount)||amount.indexOf(" ")!=-1) {
			errMsg = errMsg + "Amount should be numeric \n";           
        }
		if(reason==null || reason==""){
			errMsg = errMsg + "Please enter reason \n";
		}
		if(item==null || item==""){
			errMsg = errMsg + "Please enter item \n";
		}
		if(trxDate==null || trxDate==""){
			errMsg = errMsg + "Please enter trxDate \n";
		}
		if(retDate==null || retDate==""){
			errMsg = errMsg + "Please enter retDate \n";
		}		
		if(interest==null || interest==""){
			errMsg = errMsg + "Please enter interest \n";
		} 
		if(isNaN(interest)||interest.indexOf(" ")!=-1) {
			errMsg = errMsg + "Interest should be numeric \n";           
        }
		if(naration==null || naration==""){
			errMsg = errMsg + "Please enter naration \n";
		}if(!checked){
			errMsg = errMsg + "Please select transaction type \n";
		}
		if(mode==null || mode==""){
			errMsg = errMsg + "Please Select mode of payment \n";
		}
		
		 if(errMsg==null || errMsg==""){
			return true;
		} else{
			alert(errMsg);
			return false;
		} 
	}
</script>

</body>
</html>